﻿$(function () {
    //boostrap基于jquery.validate的验证
    var mvcbootstrap_validate_options = {
        errorClass: "help-block",
        highlight: function (element) {
            $(element).closest(".form-group").addClass("has-error has-feedback").removeClass("has-success");
            var icon = '<span class="glyphicon glyphicon-remove form-control-feedback"></span>';
            $(element).parent().find(".form-control-feedback").remove().end().append(icon);
        },
        unhighlight: function (element) {
            $(element).closest(".form-group").addClass("has-success has-feedback").removeClass("has-error");
            var icon = '<span class="glyphicon glyphicon-ok form-control-feedback"></span>';
            $(element).parent().find(".form-control-feedback").remove().end().append(icon);
        },

    };
    //向页面上所有表单扩展boostrap验证
    $("form").each(function () { $.extend($(this).data("validator").settings, mvcbootstrap_validate_options); })
})